package api

import (
	"2212b/awesomeProject12/api/handler"
	"2212b/awesomeProject12/consts"
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
)

func ToadRouter(r *gin.Engine) {
	api := r.Group("api")
	{
		user := api.Group("user")
		{
			user.POST("/login", handler.Login)
			user.Use(jwt.JWTAuth(consts.JWT_KEY))
			user.POST("/list", handler.GetUserList)
		}
		friend := api.Group("friend")
		{
			friend.Use(jwt.JWTAuth(consts.JWT_KEY))
			friend.POST("/add", handler.AddFriend)       //发起好友
			friend.POST("/reply", handler.ReplyFriend)   //回复好友
			friend.POST("/remove", handler.RemoveFriend) //删除好友
		}
		chat := api.Group("chat")
		{
			chat.Use(jwt.JWTAuth(consts.JWT_KEY))
			chat.GET("/ws", handler.Chat)          //一对一聊天
			chat.GET("/list", handler.GetChatList) //聊天记录
		}
	}
}
